/*
 * @Author: zhang zhijiang 2824735304@qq.com
 * @Date: 2025-03-22 19:38:24
 * @LastEditors: zhang zhijiang 2824735304@qq.com
 * @LastEditTime: 2025-03-22 20:30:12
 * @FilePath: /linux/test_3_22/main.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include"blockqueue.hpp"
static  int data = 0;
void * consumer(void* argvs)
{
    blockqueue<int>* bq = static_cast<blockqueue<int>*> (argvs);
    while(1)
    {
        //消费
        int x = bq->pop();
        cout<<"消费了一个数据"<<x<<endl;
        sleep(3);
    }

}
void* productor(void* argvs)
{
    blockqueue<int>* bq = static_cast<blockqueue<int>*> (argvs);
    while(1)
    {
        //生产
        cout<<"生产了一个数据"<<endl;
        bq->push(1);
        sleep(3);
    }
}
int main()
{
    pthread_t c,p;
    blockqueue<int>* bq = new blockqueue<int>(20);
    pthread_create(&c,nullptr,consumer,bq);
    pthread_create(&c,nullptr,productor,bq);
    pthread_join(c,nullptr);
    pthread_join(p,nullptr);

    return 0;
}